<?php
/**
 * Css
 */
$css1 = array(
    array("library/twitterboopstrap/css/bootstrap.min.css", false)
);

$css2 = array(
    array("library/jqueryui/css/ui-lightness/jquery-ui-1.8.21.custom.css", true),
    array("library/twitterboopstrap/css/bootstrap-responsive.css", true),
    array("library/tablesort/css/style.css", true)
);
/**
 * Javascripts
 */
$js1 = array(
    array("library/jquery/jquery.min.js", true),
    array("library/twitterboopstrap/js/bootstrap.min.js", true),
    array("library/validate/jquery.validate.pt-Br.js", true),
    array("js/util.js", true)
);

use br\com\cf\library\core\cache\Cache;
?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <title><?php print(CF_APP_NAME); ?></title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">

        <?php Cache::factory()->css($css1)->output()->clean(); ?>        

        <style type="text/css">
            body {
                padding-top: 60px;
                padding-bottom: 40px;
                background-image: url('/img/wallpaper.jpg');
            }
            .hero-unit{
                background-color: #fff
            }
            #message-box{
                display: none;
            }
        </style>

        <?php Cache::factory()->css($css2)->output()->clean(); ?>        

        <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
          <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->

        <?php Cache::factory()->js($js1)->output()->clean(); ?>          

    </head>

    <body>

        <div class="container">

            <!-- Main hero unit for a primary marketing message or call to action -->
            <div class="hero-unit">
                <h1>Hello World (CF)!</h1>
                <p>Cerberos Framework (v1.0)</p>

                <hr>
                <hr>

                <h2>Autenticação</h2>
                <hr>
                <fieldset>
                    <form id="formAuthUsuario" method="post" action="/usuario/auth/ajax/true">
                        <div class="control-group">
                            <label class="control-label" for="tx_email">Email</label>
                            <div class="controls">
                                <input class="input-xlarge focused required email" id="tx_email" name="tx_email" type="text" maxlength="50">
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="vl_produto">Senha</label>
                            <div class="controls">
                                <input class="input-xlarge focused required" id="tx_senha" name="tx_senha" type="password">
                            </div>
                        </div>
                        <div class="">
                            <button type="submit" class="btn btn-primary">Entrar</button>
                        </div>
                    </form>
                </fieldset>
            </div>

            <!--messagebox-->
            <div class="modal" id="message-box">
                <div class="modal-header">
                    <a class="close" data-dismiss="modal">×</a>
                    <h3 class="title"></h3>
                </div>
                <div class="modal-body">
                    <p class="content"></p>
                </div>
                <div class="modal-footer">
                    <a href="#" class="btn btn-primary close-message-box">Ok</a>
                </div>
            </div>

            <footer>
                <p>&copy; <?php print(CF_APP_NAME); ?></p>
            </footer>
        </div> <!-- /container -->
    </body>
</html>

<script type="text/javascript">

        !(function($){
        'use strict'
        $(document).ready(function(){
                
            // Validacao do Formulario : Novo Produto
            var process = false;
            var formNew = $('#formAuthUsuario');
            var actionNew = formNew.attr('action');
       
            $("#formAuthUsuario").validate({
                errorClass: "help-inline",
                submitHandler: function() {
                    if(!process){
                        process = true;
                        $.post(actionNew, formNew.serialize(), function(response){
                            if(response.status == 'success'){
                                window.location = response.url;
                            }else{
                                Util.showMessageBox(response);
                            }                        
                            process = false;
                        }, 'json');  
                    }
                }
            });
        
        });


    })(jQuery);


</script>